package com.ruanyun.util;

import com.ruanyun.api.core.constant.JwtConstants;
import com.ruanyun.api.core.util.JwtTokenUtil;

import javax.servlet.http.HttpServletRequest;

public class RegaxUserIdUtil {

    public static String getUserId(HttpServletRequest request){

        String requestHeader = request.getHeader(JwtConstants.AUTH_HEADER);
        if(null !=requestHeader && requestHeader.length()>7 && !"".equals(requestHeader)){
            String authToken = requestHeader.substring(7);
            String userId = JwtTokenUtil.getUsernameFromToken(authToken);
            return userId;
        }else{
            return null;
        }
    }
}
